/*
 * $Id: PerforceException.java 23 2002-09-29 13:59:30Z bpruessmann $
 * 
 * Copyright (c) 2001 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.p4eclipse.core;

import java.io.IOException;

import net.sourceforge.p4eclipse.ui.PerforceUIPlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.TeamException;

/**
  * @version 	$Revision: 23 $
  * @author		<a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class PerforceException extends TeamException
{
	public PerforceException(IStatus status)
	{
		super(status);
	}

	/*
	 * Static helper methods for creating exceptions.
	 */
	public static PerforceException wrapException(IResource resource,
	                                              String message,
	                                              IOException e)
	{
		return new PerforceException(
			new Status(IStatus.ERROR, PerforceUIPlugin.ID, IO_FAILED, message, e));
	}
	
	public static PerforceException  wrapException(IResource resource,
	                                               String message,
	                                               CoreException e)
	{
		return new PerforceException(
			new Status(IStatus.ERROR, PerforceUIPlugin.ID, UNABLE, message, e));

	}
	
	public static PerforceException wrapException(CoreException e) 
	{
		return new PerforceException(e.getStatus());
	}	
}